package sk.naive.talker.util;

import java.util.*;

/**
 * Review buffer.
 *
 * @author <a href="mailto:virgo@naive.deepblue.sk">Richard "Virgo" Richter</a>
 * @version $Revision: 1.2 $ $Date: 2004/03/01 22:58:53 $
 */
public class Buffer {
	private List list;
	private int maxSize;

	public Buffer(int maxSize) {
		this.list = new LinkedList();
		this.maxSize = maxSize;
	}

	public boolean add(Object o) {
		boolean retVal = list.add(o);
		while (list.size() > maxSize) {
			list.remove(0);
		}
		return retVal;
	}

	public Iterator iterator() {
		return list.iterator();
	}

	public void clear() {
		list.clear();
	}

	public int size() {
		return list.size();
	}
}
